package br.com.localfloripa.dao;

import java.util.List;

import javax.inject.Named;
import javax.persistence.Query;

import br.com.localfloripa.entities.Categoria;

@Named("categoriaDao")
public class CategoriaDao extends DaoManager<Categoria> {

	public Categoria findById(Long idCategoria) throws Exception {
		return em.find(Categoria.class, idCategoria);
	}
	
	public List<Categoria> listCategoriasOrdemNome() throws Exception {
		Query query = em.createQuery("SELECT c FROM Categoria c WHERE c.ativo IS TRUE ORDER BY c.nome");
		return query.getResultList();
	}
	
}
